<template>
  <div class="app-container">
    <div class="search-container">
      <el-form inline>
        <el-form-item label="名称">
          <el-input />
        </el-form-item>
        <el-button type="primary">搜索</el-button>
        <!-- <el-button type="primary" @click="operate('add')">新增</el-button> -->
        <!-- <el-button type="primary">导入</el-button>
        <el-button type="primary">导出</el-button> -->
      </el-form>
    </div>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column label="老人姓名" width="110px" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="编号" align="center">
        <template slot-scope="scope">
          {{ scope.row.id }}
        </template>
      </el-table-column>
      <el-table-column label="年龄" align="center">
        <template slot-scope="scope">
          {{ scope.row.age }}
        </template>
      </el-table-column>
      <el-table-column label="性别" align="center">
        <template slot-scope="scope">
          {{ scope.row.sex }}
        </template>
      </el-table-column>
      <el-table-column label="联系人" width="100" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.person }}</span>
        </template>
      </el-table-column>
      <el-table-column label="联系方式" width="140" align="center">
        <template slot-scope="scope">
          {{ scope.row.phone }}
        </template>
      </el-table-column>

      <el-table-column label="呼叫时间" width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.display_time }}
        </template>
      </el-table-column>
      <!-- <el-table-column
        class-name="status-col"
        label="项目状态"
        width="110"
        align="center"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{
            scope.row.status | statusFilterLabel
          }}</el-tag>
        </template>
      </el-table-column> -->

      <el-table-column label="处理时间" width="180" align="center">
        <template slot-scope="scope">
          {{ scope.row.display_time }}
        </template>
      </el-table-column>
      <el-table-column label="处理人员" width="120" align="center">
        <template slot-scope="scope">
          {{ scope.row.user }}
        </template>
      </el-table-column>
      <!-- <el-table-column align="center" prop="created_at" label="Display_time" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="操作" width="180" align="center" fixed="right">
        <template slot-scope="scope">
          <!-- <el-button
            type="primary"
            size="mini"
            :disabled="scope.row.status == 0"
            >发布</el-button
          >
          <el-button
            type="warning"
            size="mini"
            :disabled="scope.row.status == 1"
            >停用</el-button
          >
          <el-button type="success" size="mini">修改</el-button>
          <el-button type="danger" size="mini">删除</el-button> -->
          <el-button type="primary" size="mini" @click="detail(scope.row)"
            >详情</el-button
          >
          <el-button type="success" size="mini" @click="apply(scope.row)"
            >处理</el-button
          >
          <!-- <el-button type="warning" size="mini" @click="apply(scope.row)"
            >申请</el-button
          >
          <el-button type="danger" size="mini">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>
    <el-dialog
      :visible.sync="dialogVisible"
      :title="title"
      width="800px"
      center
    >
      <el-form ref="form" :model="form" label-width="120px" inline size="small">
        <div>
          <span class="title">老人信息</span>
        </div>
        <el-descriptions style="margin:20px 0" :column="3" :size="size" border>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-user"></i>
              姓名
            </template>
            张三
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-mobile-phone"></i>
              手机号
            </template>
            137****8980
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-location-outline"></i>
              年龄
            </template>
            46
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-tickets"></i>
              性别
            </template>
            <el-tag size="small">男</el-tag>
          </el-descriptions-item>
          <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-office-building"></i>
              联系地址
            </template>
            拱墅区祥园路
          </el-descriptions-item>
        </el-descriptions>
        <div>
          <span class="title">处理记录</span>
        </div>
        <el-table
          :data="listData"
          element-loading-text="Loading"
          border
          fit
          highlight-current-row
          style="margin:20px 0"
        >
          <el-table-column align="center" label="编号" width="65">
            <template slot-scope="scope">
              {{ scope.$index }}
            </template>
          </el-table-column>

          <el-table-column label="处理人员" width="100" align="center">
            <template slot-scope="scope">
              {{ scope.row.user }}
            </template>
          </el-table-column>
          <el-table-column label="职位" width="100" align="center">
            <template slot-scope="scope">
              {{ scope.row.position }}
            </template>
          </el-table-column>
          <el-table-column label="呼叫时间" min-width="180" align="center">
            <template slot-scope="scope">
              {{ scope.row.time }}
            </template>
          </el-table-column>
          <el-table-column label="处理时间" min-width="180" align="center">
            <template slot-scope="scope">
              {{ scope.row.endtime }}
            </template>
          </el-table-column>

          <el-table-column
            class-name="status-col"
            label="状态"
            width="110"
            align="center"
          >
            <template slot-scope="scope">
              <el-tag :type="scope.row.status | statusFilter">{{
                scope.row.status | statusFilterLabel
              }}</el-tag>
            </template>
          </el-table-column>
          <!-- <el-table-column
            label="操作"
            width="180"
            align="center"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button
                type="success"
                size="mini"
                @click="operate('edit', scope.row)"
                >修改</el-button
              >
              <el-button type="danger" size="mini">删除</el-button>
            </template>
          </el-table-column> -->
        </el-table>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="onSubmit">提交</el-button>
        <el-button @click="onCancel">取消</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getList } from "@/api/table";

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        0: "success",
        1: "gray",
        2: "danger",
        3: "warning"
      };
      return statusMap[status];
    },
    statusFilterLabel(status) {
      const statusMap = {
        0: "处理中",
        1: "已处理",
        2: "未处理",
        3: "待启动"
      };
      return statusMap[status];
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      data: [
        {
          name: "张三",
          age: "46",
          sex: "男",
          person: "李响",
          phone: "137****8980",
          card_id: "3307********8980",
          display_time: "2023-12-24 16:10:10",
          id: "2104623",
          user: "李三"
        },
        {
          name: "李四",
          age: "46",
          sex: "男",
          person: "李响",
          phone: "137****8980",
          card_id: "3307********8980",
          display_time: "2023-12-24 16:10:10",
          id: "2104623",
          user: "李三"
        },
        {
          name: "王五",
          age: "46",
          sex: "男",
          person: "李响",
          phone: "137****8980",
          card_id: "3307********8980",
          display_time: "2023-12-24 16:10:10",
          id: "2104623",
          user: "李三"
        }
      ],
      dialogVisible: false,
      title: "报警详情",
      personList: [{ label: "张三", value: "0" }],
      numList: [
        { label: "每年", value: "0" },
        { label: "每月", value: "1" },
        { label: "每日", value: "2" }
      ],
      typeList: [
        { label: "消防安全", value: "0" },
        { label: "食堂安全", value: "1" },
        { label: "护工查房", value: "2" }
      ],
      form: {},
      checkList: ["日常清洁", "定期体检", "心理咨询"],
      listData: [
        {
          name: "张三",
          user: "李响",
          logo: "",
          sex: "女",
          tel: "13788890000",
          role: "项目负责人",
          dept: "项目部",
          position: "部门经理",
          time: "2023-12-24 16:10:10",
          status: 2,
          endtime: ""
        },
        {
          user: "李响",
          name: "李四",
          logo: "",
          sex: "男",
          tel: "13788890000",
          role: "评估员",
          dept: "管理部",
          position: "员工",
          time: "2023-12-24 16:10:10",
          status: 0,
          endtime: ""
        },
        {
          user: "李响",
          name: "王五",
          logo: "",
          sex: "男",
          tel: "13788890000",
          role: "施工人员",
          dept: "服务部",
          position: "员工",
          time: "2023-12-24 16:10:10",
          status: 1,
          endtime: "2023-12-24 16:10:10"
        }
      ]
    };
  },
  created() {
    this.fetchData();
  },
  methods: {
    fetchData() {
      this.listLoading = true;
      this.list = this.data;
      this.listLoading = false;
      // getList().then(response => {
      //   this.list = response.data.items
      //   this.listLoading = false
      // })
    },
    operate(type) {
      if (type === "add") {
        this.dialogVisible = true;
      }
    },
    detail(row) {
      this.form = row;
      this.dialogVisible = true;
    },
    fileDetail(row) {
      this.$router.push({ name: "OldDetail" });
    },
    onSubmit() {
      this.$message("submit!");
    },
    onCancel() {
      this.dialogVisible = false;
    }
  }
};
</script>
<style scoped lang="scss">
.line {
  text-align: center;
}
.title {
  margin-bottom: 20px;
  font-weight: 600;
  left: -5px;
}
.title::before {
  // content: "";
  // display: inline-block;
  // width: 2px;
  // height: 20px;
  // background: pink;
  // margin: 0 5px;

  content: "";
  width: 3px;
  height: 16px;
  position: absolute;
  margin: 0 -8px;
  background: rgb(32, 125, 255);
}
.medical-row {
  ::v-deep.el-form-item__content {
    width: 80%;
  }
}
</style>
